<%
    /**
     * 初始化打印列
     *
     * created by amon 2005-12-21
     */
%>
<%@ include file = "/common/ini.jsp"%>
<%@ include file = "/common/_log4j.jsp"%>
<%@ include file = "/common/_ApplicationContext_init.jsp"%> 
<%@ include file = "/common/_currUser_Infor.jsp"%>
<%@ include file = "/common/params/_getParamsInSession.jsp"%>
<%@ include file = "/common/params/iniParamsForm.jsp"%>
<%@ include file = "/common/List/2excel/getTitleAndList.jsp"%>
<%@ include file = "/css/detailcss.jsp"%>
<%
    String userId = currUser.getId();
    String userName = currUser.getName();
    ServiceTO serviceTO = (ServiceTO)request.getAttribute("serviceTO");
%>
<%@ include file = "/common/List/_configColumn/getCurrServiceColumnConfig.jsp" %>
<%
        logger.info("导出excel");
        Date now = new Date();
        SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddhhmm");
        SimpleDateFormat sdf4sheet = new SimpleDateFormat("yyyy-MM-dd");
        String fileName = sdf.format(now) + userId +".xls";
        String titleName = "";
        // 取标题名
        FIArea fiArea = (FIArea)request.getAttribute("viewer");
        logger.debug("  -- 取功能切换区");
        List fis = fiArea.getChanges(request.getContextPath());
        logger.debug("  -- 显示功能切换明细");
        for(int i = 0; i < fis.size(); i ++)
        {
            FuncItem fi = (FuncItem)fis.get(i);
            if(fi.isFocus())
            {
                titleName = fi.getText();
                break;
            }// if
        }
        String sheetName = sdf4sheet.format(now);
        int maxLength = 0; // 记录数
        int reportHeight = 2; // 头部占多少行
        // 打印标题
        HSSFWorkbook wb = new HSSFWorkbook();
        // 创建sheet
        HSSFSheet sheet = wb.createSheet(sheetName);
%>

<!-- 1. 创建标题区域 -->
<%@ include file = "/common/List/2excel/outPrintTitles.jsp" %>
<!-- 2. 创建明细区域 -->
<%@ include file = "/common/List/2excel/outPrintItems.jsp" %>
<!-- 3. 创建报表头 -->
<%@ include file = "/common/List/2excel/getHead.jsp" %>
<!-- 4. 创建创建人信息区域 -->
<%@ include file = "/common/List/2excel/outPrintMakerInfor.jsp" %>
<%
        // 生成文件
        FileOutputStream fileOut = new FileOutputStream(fileName);
        wb.write(fileOut);
        fileOut.close();
        logger.info("生成excel文件: " +  fileName);
        
%>
<script>
    window.location.href="<%= request.getContextPath()%>/common/List/2excel/_download.jsp?fileName=<%= fileName%>";
</script>
